home *** CD-ROM | disk | FTP | other *** search
/ Group 42-Sells Out! - The Information Archive / Group 42 Sells Out (Group 42) (1996).iso / faqs / cscomp.txt < prev    next >
Text File  |  1995-11-30  |  15KB  |  314 lines

  1. Archive-name: computer-security/compromise-faq 
  2. Posting-frequency: monthly
  3. Last-Modified: 1995/4/05
  4. Version: 2.0
  5.  
  6. Compromise FAQ
  7.  
  8. Version: 2.0
  9. -------------------------------------------------------------------------------
  10. This Security FAQ is a resource provided by:
  11.  
  12.      Internet Security Systems, Inc.
  13.      2000 Miller Court West            Tel: (770) 441-2531
  14.      Norcross, Georgia  30071          Fax: (770) 441-2431
  15.  
  16.      - Internet Scanner ... the most comprehensive "attack simulator"
  17.      available. -
  18.  
  19. -------------------------------------------------------------------------------
  20. To get the newest updates of Security files check the following services:
  21.  
  22.      mail info@iss.net with "send index" in message
  23.      http://iss.net/
  24.      ftp iss.net /pub/
  25.  
  26. -------------------------------------------------------------------------------
  27.  
  28. What if your Machines are Compromised by an Intruder.
  29.  
  30. This FAQ deals with some suggestions for securing your Unix machine after it
  31. has already been compromised. Even if your machines have not been compromised,
  32. there are many helpful tips on securing a machine in this paper.
  33.  
  34.   1.  Try to trace/follow the intruder back to his origin via looking at
  35.  
  36.        1.  who
  37.        2.  w
  38.        3.  last
  39.        4.  lastcomm
  40.        5.  netstat
  41.        6.  snmpnetstat
  42.        7.  router information.
  43.        8.  /var/adm/messages (many crackers send e-mail to their "home"
  44.           accounts)
  45.        9.  syslog (sends logs to other hosts as well)
  46.       10.  wrapper logs
  47.       11.  do a 'finger' to all local users(and check where they last logged in
  48.           from)
  49.       12.  history files from shells, such as .history, .rchist, and similiar
  50.           files.
  51.  
  52.      Footnote: 'who', 'w', 'last', and 'lastcomm' are commands that rely on
  53.      /var/adm/pacct, /usr/adm/wtmp, and /etc/utmp to report the information to
  54.      you. Most backdoors will keep the intruder from being shown in these logs.
  55.      Even if the intruder has not installed any backdoors yet, it is trivial to
  56.      remove any detection in these logs. But they may just forget about one or
  57.      two of them. Especially if you have some additional, non-standard ones.
  58.  
  59.      Suggestion: Install xinetd or tcp_wrapper that will log all connections to
  60.      your machine to see if someone is knocking on its doors. Forward syslogs
  61.      to another machine so intruder will not easily detect the logs and modify.
  62.      Other possibilities: netlog from net.tamu.edu:/pub/security.
  63.  
  64.      It might be wise to monitor the intruder via some ethernet sniffer to see
  65.      how he is exploiting his systems before taking corrective measures.
  66.  
  67.   2.  Close the machine from outside access. Remove from network to stop
  68.      further access via intruder. If the intruder finds out that the
  69.      administrator is unto him, he may try to hide his tracks by rm -rf /.
  70.  
  71.   3.  Check the binaries with the originals. Especially check the following
  72.      binaries because they are commonly replaced backdoors for regaining
  73.      access:
  74.  
  75.        1.  /bin/login
  76.        2.  all the /usr/etc/in.* files (ie. in.telnetd)
  77.        3.  and /lib/libc.so.* (on Suns).
  78.        4.  anything called from inetd
  79.  
  80.      Other commonly replaced backdoor binaries:
  81.  
  82.        1.  netstat - allows hiding connections
  83.        2.  ps - allows hiding processes (ie Crack)
  84.        3.  ls - allows hiding directories
  85.        4.  ifconfig - hides the fact that promiscuity mode is on the ethernet
  86.        5.  sum - fools the checksum for binaries, not necessarily replaced
  87.           anymore because its possible to change the checksum of the binaries
  88.           to the correct value without modifying sum. *EMPHASIZE* Do NOT Rely
  89.           on sum.
  90.  
  91.      Use 'ls -lac' to find the real modification time of files. Check /etc/wtmp
  92.      (if you still have one) for any system time adjustments. Check the files
  93.      with the distribution media (CD or tape) or calculate MD5 checksums and
  94.      compare them with the originals kept offline (you did calculate them
  95.      sometime ago, didn't you?) Suggestion: cmp the files with copies that are
  96.      known to be good.
  97.  
  98.      Another popular backdoor is suid'ing a common command (ie. /bin/time) to
  99.      allow root access with regular accounts.
  100.  
  101.      To find all suid programs you may use:
  102.  
  103.           find / -type f -perm -4000 -ls
  104.  
  105.      To be thorough you may need to re-load the entire OS to make sure there
  106.      are no backdoors. Tripwire helps prevent modifying binaries and system
  107.      files (ie. inetd.conf) on the system, without the administrator knowing.
  108.  
  109.   4.  Implement some password scheme for your users to verify that they change
  110.      their passwords often. Install anlpasswd, npasswd, or passwd+ in place of
  111.      passwd (or yppasswd) so that your users are forced to set reasonable
  112.      passwords. Then run Crack, which is available on
  113.      ftp.cert.org:/pub/tools/crack to make sure that your users aren't
  114.      bypassing the password check. Crack ensures that users are picking
  115.      difficult passwords. With the network, clear text passwords are a problem.
  116.      Other possible choices: smart hubs (stops ethernet sniffing of the whole
  117.      LAN) and one-time password technology.
  118.  
  119.   5.  Check all the users' .rhosts and .forward files to make sure none of them
  120.      are weird or out of the ordinary. If .rhosts file contains '+ +', the
  121.      account can be accessed anywhere by anyone without a password. COPS has a
  122.      scripts for checking .rhosts.
  123.  
  124.           find / -name .rhosts -ls -o -name .forward -ls
  125.  
  126.      Look also for all the files created/modified in the time you are
  127.      suspecting the break-in has taken place, eg:
  128.  
  129.           find / -ctime -2 -ctime +1 -ls
  130.  
  131.      To find all the files modified not less than one day ago, but not more
  132.      than 2.
  133.  
  134.      All .login, .logout, .profile, .cshrc files are also worth looking at (at
  135.      least for the modification date/time). Make sure there are no '.rhosts'
  136.      for the locked or special accounts (like 'news', 'sundiag', 'sync', etc.)
  137.      The shell for such accounts should be something like '/bin/false' anyway
  138.      (and not '/bin/sh') to make them more secure. Also search for directories
  139.      that have like ". ", ".. " as names. They are usually found in /tmp ,
  140.      /var/tmp, /usr/spool/* and any other publicly writeable directory.
  141.  
  142.   6.  Check to make sure your NFS exports are not world writable to everyone.
  143.      NFSwatch available on harbor.ecn.purdue.edu:/pub/davy , a program by David
  144.      Curry, will log any NFS transactions that are taking place. Try 'showmount
  145.      -e' to see whether system agrees with your opinion of what are you
  146.      exporting and where. There are bugs in some nfsd implementations which
  147.      ignore the access lists when they exceed some limit (256 bytes). Check
  148.      also what are you IMPORTING!!! Use 'nosuid' flag whenever possible. You do
  149.      not want to be cracked by a sysadm from another host (or a cracker there)
  150.      running suid programs mounted via NFS, do you?
  151.  
  152.   7.  Make sure you have implemented the newest sendmail daemon. Old sendmail
  153.      daemons allowed remote execution of commands on any Unix machine. See the
  154.      computer-security/security-patch FAQ.
  155.  
  156.   8.  Try to install all the security patches available from the vendor on your
  157.      machine. See the computer-security/security-patch FAQ.
  158.  
  159.   9.  Here is a check list of common ways that a machine is vulnerable:
  160.  
  161.        1.  Do an rpcinfo -p on your machine to make sure it is not running any
  162.           processes that are not needed. (ie. rexd).
  163.  
  164.        2.  Check for '+' in /etc/hosts.equiv.
  165.  
  166.        3.  Check whether tftp is disabled on your system. If not - disable it,
  167.           or at least use '-s' flag to chroot it to some safe area, if you
  168.           really can't live without it (it is mostly used for booting up
  169.           Xterminals, but sometimes can be avoided by NFS-mounting appropriate
  170.           disks). Under no circumstances you should run it as root. Change the
  171.           line describing it in /etc/inetd.conf to something like:
  172.  
  173.                tftp dgram udp wait nobody /usr/etc/in.tftpd in.tftpd -s
  174.                /tftpboot
  175.  
  176.           or better yet, use tcpd wrapper program to protect it from addresses
  177.           which should not get access to tftp and log all other connections:
  178.  
  179.                tftp dgram udp wait nobody /usr/etc/tcpd in.tftpd -s
  180.                /tftpboot
  181.  
  182.           and edit appropriately /etc/hosts.allow to restrict access to
  183.           in.tftpd to only those addresses that really need it.
  184.  
  185.        4.  Check crontabs and at-jobs. Make sure there are no delayed bombs
  186.           which will explode after you think you have got rid of all the nasty
  187.           things left by a intruder.
  188.  
  189.        5.  Check /etc/rc.boot /etc/rc.local (SYSV: /etc/rc?.d/* ) and other
  190.           files cruicial for the system startup. (The best would be if you
  191.           could compare them with the copies kept off-line). Check all other
  192.           files containing system configuration (sendmail.cf, sendmail.fc,
  193.           hosts.allow, at.allow, at.deny, cron.allow, hosts, hosts.lpd, etc.)
  194.           In 'aliases' look for aliases expanding to some unusual programs
  195.           (uudecode is one but example).
  196.  
  197.        6.  Check your inetd.conf and /etc/services files to find if there are
  198.           no additional services set up by an intruder.
  199.  
  200.        7.  Copy all the log files you still have (pacct, wtmp, lastlog, sulog,
  201.           syslog, authlog, any additional logs you have set up earlier) to some
  202.           safe place (offline) so you may examine them later. Otherwise, do not
  203.           be surprised if they disappear the next day when the cracker realises
  204.           he forgot to remove one of them. Use your own imagination to find
  205.           what other traces he could have left in your system (What about
  206.           /tmp/* files? Check them BEFORE you reboot).
  207.  
  208.        8.  Make backup copy of /etc/passwd (best offline) then change all root
  209.           passwords (after verifying that 'su' and 'passwd' are not the trojan
  210.           versions left by an intruder). It may sound like a horrible thing to
  211.           do (especially if you have something like 2000 users) but *do* lock
  212.           them all by putting '*' in the password field. If the intruder has a
  213.           copy of your passwords file he may possibly sooner or later guess all
  214.           the passwords contained there (It is all the matter of proper
  215.           dictionaries). In fact he could have inserted few passwords that he
  216.           only knows for some users who for example have not logged in for a
  217.           long time.
  218.  
  219.           On the NIS servers check not only the real /etc/passwd /etc/groups
  220.           etc files but also those used for building NIS maps (if they are
  221.           different).
  222.  
  223.        9.  Check if your anonymous ftp (and other services) are configured
  224.           properly (if you have any of course) See the
  225.           computer-security/anonymous-ftp FAQ.
  226.  
  227.       10.  If you want to make your life easier next time (or if you still
  228.           cannot get rid of an intruder) consider installing 'ident' daemon.
  229.           Together with tcpd on a set of hosts it can be used to find what
  230.           accounts the intruder is using.
  231.  
  232.       11.  Make sure the only 'secure' terminal is console (if at all). This
  233.           way you prevent root logins just from the net. Maybe it is not a big
  234.           deal as if somebody knows the root password he may already know other
  235.           peoples' passwords too, but maybe not?
  236.  
  237.       12.  Check hosts.equiv, .rhosts, and hosts.lpd for having # as comments
  238.           within those files. If an intruder changes his hostname to #, it will
  239.           be considered a trusted host and allow him to access your machines.
  240.  
  241.       13.  And remember... There are so many ways that somebody could have
  242.           modified your system, that you really have to have your eyes and ears
  243.           wide open for a loooooong long time. Above, are the pointers just to
  244.           the most obvious things to check.
  245.  
  246.  10.  Mail all the sites that you were able to find out that the intruder was
  247.      going through and warn them. Also, CC: cert@cert.org. Check all the sites
  248.      in your near-by, ie. in your domain/institution/whatever. It's usually
  249.      trivial for a hacker to get to another system by a simple 'rlogin' if the
  250.      two systems have a common subset of users (and using .rhosts to make the
  251.      access easier).
  252.  
  253.  11.  A preventive from stopping many intruders from even trying your network
  254.      is to install a firewall.
  255.  
  256.      Side-effects: Firewalls may be expensive; filtering may slow down the
  257.      network. Consider blocking nfs (port 2049/udp) and portmap(111/udp) on
  258.      your router. The authentication and access controls of these protocols is
  259.      often minimal. Suggestion: Block all udp ports except DNS and NTP ports.
  260.      Kill all source routing packets. Kill all ip-forwarding packets.
  261.  
  262. Acknowledgements
  263.  
  264. Thanks to the following people for adding and shaping this FAQ:
  265.  
  266. Tomasz Surmacz <tsurmacz@asic.ict.pwr.wroc.pl>
  267. Wes Morgan (morgan@engr.uky.edu)
  268. Alan Hannan (alan@noc1.mid.net)
  269. Peter Van Epp <vanepp@sfu.ca>
  270. Richard Jones <electron@suburbia.apana.org.au>
  271. Wieste Venema <wietse@wzv.win.tue.nl>
  272. Adrian Rodriguez <adrian@caip.rutgers.edu>
  273. Jill Bowyer <jbowyer@selma.hq.af.mil>
  274. Andy Mell <amell@cup.cam.ac.uk>
  275.  
  276. -------------------------------------------------------------------------------
  277.  
  278. Copyright
  279.  
  280. This paper is Copyright (c) 1994, 1995
  281.    by Christopher Klaus of Internet Security Systems, Inc.
  282.  
  283. Permission is hereby granted to give away free copies electronically. You may
  284. distribute, transfer, or spread this paper electronically. You may not pretend
  285. that you wrote it. This copyright notice must be maintained in any copy made.
  286. If you wish to reprint the whole or any part of this paper in any other medium
  287. excluding electronic medium, please ask the author for permission.
  288.  
  289. Disclaimer
  290.  
  291. The information within this paper may change without notice. Use of this
  292. information constitutes acceptance for use in an AS IS condition. There are NO
  293. warranties with regard to this information. In no event shall the author be
  294. liable for any damages whatsoever arising out of or in connection with the use
  295. or spread of this information. Any use of this information is at the user's own
  296. risk.
  297.  
  298. Address of Author
  299.  
  300. Please send suggestions, updates, and comments to:
  301. Christopher Klaus <cklaus@iss.net> of Internet Security Systems, Inc.
  302. <iss@iss.net>
  303.  
  304. Internet Security Systems, Inc.
  305.  
  306. Internet Security Systems, Inc, located in Atlanta, Ga., specializes in the
  307. developement of security scanning software tools. Its flagship product,
  308. Internet Scanner, is software that learns an organization's network and probes
  309. every device on that network for security holes. It is the most comprehensive
  310. "attack simulator" available, checking for over 100 security vulnerabilities.
  311. -- 
  312.  
  313.  
  314.